package 设计模式.iterator;

import java.util.Iterator;
import java.util.List;

public class OutPutImpl {
    List<College> collegeList;
    public OutPutImpl(List<College> collegeList){
        this.collegeList=collegeList;
    }
    public void printCollege(){
        Iterator<College> iterator=collegeList.iterator();
        while (iterator.hasNext()){
            College college=iterator.next();
            System.out.println("==="+college.getName()+"===");
            printDeepartment(college.createIterator());
        }
    }

    public void printDeepartment(Iterator iterator){
        while (iterator.hasNext()){
            Department d=(Department) iterator.next();
            System.out.println(d.getName());
        }
    }
}
